![@thi.ng/geom-tessellate](https://media.thi.ng/umbrella/banners-20230807/thing-geom-tessellate.svg?03f4de89)
![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)
[!NOTE]
This is one of 201 standalone projects, maintained as part
of the @thi.ng/umbrella monorepo
and anti-framework.
🚀 Please help me to work full-time on these projects by sponsoring me on
GitHub. Thank you! ❤️
About
2D/3D convex polygon tessellators. This is a support package for @thi.ng/geom.
Tessellators
The following tessellator algorithms are provided, but the package is designed
to be fully extensible. See code examples further below.
The following diagrams each show the effect of a single tessellator applied to a
triangle, square, hexagon and octagon.
Ear cut
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/ear-cut.png)
Complex polygons
Higher order tessellator for concave polygons and/or polygons with holes...
TODO add comments, credits & example
Edge split
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/edge-split.png)
Inset
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/inset.png)
Higher order tessellator with configurable inset distance (normalized) toward
centroid and option to keep center polygon (empty by default).
Quad fan
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/quad-fan.png)
Rim triangles
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/rim-tris.png)
Tri fan (with boundary point)
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/tri-fan-boundary.png)
Tri fan (with centroid)
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/tri-fan.png)
Tri fan (with edge splitting)
![diagram of tessellated polygons](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom-tessellate/tri-fan-split.png)
The ITessellation
interface & implementation
The tessellators provided all operate in conjunction with a
ITessellation
implementation which is used to collect (or index) points/vertices and generated
faces (not necessarily triangles).
Currently, there're two implementations available:
BasicTessellation
is used as the default and merely collects points & faces into arraysMeshTessellation
uses a kD-tree to deduplicate/weld and re-use points (with configurable
tolerance) and is recommended for use cases when the result tessellation
should be converted or used for graph-like analysis or other post-processing.
Status
STABLE - used in production
Search or submit any issues for this package
Installation
yarn add @thi.ng/geom-tessellate
ESM import:
import * as gt from "@thi.ng/geom-tessellate";
Browser ESM import:
<script type="module" src="https://esm.run/@thi.ng/geom-tessellate"></script>
JSDelivr documentation
For Node.js REPL:
const gt = await import("@thi.ng/geom-tessellate");
Package sizes (brotli'd, pre-treeshake): ESM: 3.32 KB
Dependencies
Note: @thi.ng/api is in most cases a type-only import (not used at runtime)
Usage examples
Three projects in this repo's
/examples
directory are using this package:
Screenshot | Description | Live demo | Source |
---|
![](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-hexgrid.png) | Hex grid generation & tessellations | Demo | Source |
![](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom/tessel.png) | Animated, recursive polygon tessellations | Demo | Source |
![](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/pointfree-geom.jpg) | Live coding playground for 2D geometry generation using @thi.ng/pointfree-lang | Demo | Source |
API
Generated API docs
This is a low(er)-level support package for thi.ng/geom
and most users are encouraged to use the polymorphic tessellate()
function
provided by that package.
In addition to the actual tessellator algorithms described above, this package
also provides its own set of tessellate()
functions to simplify
recursive/iterative application of multiple tessellation passes:
Basic usage
import * as gt from "@thi.ng/geom-tessellate";
const points = [[0,0], [100,0], [100,100], [0, 100]];
console.log(gt.tessellate(points, gt.triFan));
console.log(gt.tessellate(points, [gt.triFan, gt.quadFan]));
console.log(gt.tessellateWith(new gt.MeshTessellation(2), points, gt.quadFan, 2));
Authors
If this project contributes to an academic publication, please cite it as:
@misc{thing-geom-tessellate,
title = "@thi.ng/geom-tessellate",
author = "Karsten Schmidt",
note = "https://thi.ng/geom-tessellate",
year = 2013
}
License
© 2013 - 2025 Karsten Schmidt // Apache License 2.0